<?php
/**
 * LG
 *
 */
namespace Home\Controller;
use Think\Controller;
class RegisterController extends Controller{
    public function Register(){
        $this->display();
    }
    public function doRegister(){
        $User = D('User');
        $User->create();
        if(in_array('on',$_POST)){
            if($_POST['username'] ==null){
                $this->error("账号不能为空！");
            }else{
                if($_POST['password'] == $_POST['repassword'] && $_POST['password'] !=null && $_POST['repassword'] !=null){
                    unset($_POST['checkbox']);
                    unset($_POST['repassword']);
                    $rs = $User->data($_POST)->add();
                    if($rs){
                        $this->success("注册成功！",U('Index/Index'));
                    }else{
                        $this->getLastSQL(ERROR());
                    }
                }else{
                    $this->error("请确认密码是否一致！");
                }
            }
        }else{
            $this->error("请勾选协议！");
        }

    }
}
?>